//
//  foundQuestSelectPondShowView.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/31.
//

#import "foundQuestSelectPondShowView.h"

@interface foundQuestSelectPondShowView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong) UIView * makeView;
@property (nonatomic ,assign) CGFloat viewH;
@property (nonatomic ,strong) UITableView * tableview;
@property (nonatomic ,strong) UILabel * seledCount;
@property (nonatomic ,strong) NSArray <pondModelListModel *> * array;
@property (nonatomic ,strong) void(^block)(NSArray <NSString *>* array);
@end

@implementation foundQuestSelectPondShowView

+ (instancetype)showviewWithArray:(NSArray <pondModelListModel *>*)array andBlock:(void(^)(NSArray <NSString *>* array))block{
    foundQuestSelectPondShowView * view = [foundQuestSelectPondShowView new];
    view.array = array;
    view.block = block;
    [view setupview];
    return view;
}
- (void)setupview{
    [[DTKTool getCurrentVC].view addSubview:self];
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    self.viewH = kwt(400) + KSafeAreaBottomHeight;
    UIView * makeView = [UIView new];
    self.makeView = makeView;
    makeView.backgroundColor = KcolorHex(@"#EDF2F8");
    makeView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, kwt(170) + KSafeAreaBottomHeight);
    [self addSubview:makeView];
    [DTKTool BFYJ:kwt(15) andView:makeView andCorner:UIRectCornerTopLeft|UIRectCornerTopRight andSize: CGRectMake(0, 0 ,SCREEN_WIDTH, self.viewH + KSafeAreaBottomHeight)];
    
//    view.userInteractionEnabled = YES;
//    [view addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:view action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
    self.userInteractionEnabled = YES;
    [self addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
    
    UILabel * titlab = [DTKTool labelWithText:@"池塘名称" andFont:kFont(18) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:titlab];
    [titlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(15));
    }];
    
    UIButton * btn = [UIButton buttonWithType:0];
    [btn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    btn.addTarget(self,@selector(dismiss));
    [makeView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.width.height.offset(kwt(20));
        make.centerY.equalTo(titlab);
    }];
    
    
    
    UIView * buttonview = [UIView new];
    [makeView addSubview:buttonview];
    buttonview.backgroundColor = UIColor.whiteColor;
    [buttonview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(kwt(68) + KSafeAreaBottomHeight);
    }];
    UILabel * temp1 = [DTKTool labelWithText:@"已选" andFont:kFont(15) andTextColor:KcolorHex(@"#5A6066")];
    [buttonview addSubview:temp1];
    [temp1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(26));
    }];
    UILabel * seledCount = [DTKTool labelWithText:@"0" andFont:kFont(15) andTextColor:KcolorHex(@"#0967FF")];
    self.seledCount = seledCount;
    [buttonview addSubview:seledCount];
    [seledCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(temp1.mas_right).offset(kwt(2));
        make.centerY.equalTo(temp1);
    }];
    
    UILabel * temp3 = [DTKTool labelWithText:@"个" andFont:kFont(15) andTextColor:KcolorHex(@"#5A6066")];
    [buttonview addSubview:temp3];
    [temp3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(seledCount.mas_right).offset(kwt(2));
        make.centerY.equalTo(temp1);
    }];
    UIButton * qxbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    qxbtn.backgroundColor = KcolorHex(@"#F0F2F4");
    [qxbtn setTitle:@"清空" forState:UIControlStateNormal];
    [qxbtn setTitleColor:KcolorHex(@"#5A6066") forState:UIControlStateNormal];
    qxbtn.titleLabel.font = kFont(17);
    [DTKTool YJ:kwt(5) andView:qxbtn];
    [qxbtn addTarget:self action:@selector(leftBtnclick) forControlEvents:UIControlEventTouchUpInside];
    [buttonview addSubview:qxbtn];
    [qxbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(kwt(44));
        make.width.offset(kwt(116));
        make.left.offset(kwt(118));
        make.top.offset(kwt(12));
    }];
    
    UIButton * qrbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    qrbtn.backgroundColor = [UIColor gradientColorWithSize:CGSizeMake(kwt(160), 1) direction:GradientColorDirectionLevel startColor:KcolorHex(@"#2892FE") endColor:KcolorHex(@"#0366FE")];
    [qrbtn setTitle:@"确定" forState:UIControlStateNormal];
    [qrbtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    qrbtn.titleLabel.font = kCFont(17);
    [DTKTool YJ:kwt(5) andView:qrbtn];
    [qrbtn addTarget:self action:@selector(rightbtnclick) forControlEvents:UIControlEventTouchUpInside];
    [buttonview addSubview:qrbtn];
    [qrbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(kwt(44));
        make.width.offset(kwt(116));
        make.right.offset(kwt(-15));
        make.top.offset(kwt(12));
    }];
    
    UIView * backview = [UIView new];
    backview.backgroundColor = UIColor.whiteColor;
    [DTKTool YJ:kwt(5) andView:backview];
    [makeView addSubview:backview];
    [backview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
        make.top.offset(kwt(47));
        make.bottom.equalTo(buttonview.mas_top).offset(kwt(-7));

    }];
    
    UILabel * toplab1= [DTKTool labelWithText:@"*" andFont:kCFont(17) andTextColor:KcolorHex(@"#FA0F0F")];
    [backview addSubview:toplab1];
    [toplab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(18));
        make.left.offset(kwt(14));
    }];
    
    UILabel * toplab2= [DTKTool labelWithText:@"选择池塘名称" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
    [backview addSubview:toplab2];
    [toplab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(toplab1);
        make.left.equalTo(toplab1.mas_right);
    }];
    
    UILabel * toplab3= [DTKTool labelWithText:@" (可多选)" andFont:kCFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
    [backview addSubview:toplab3];
    [toplab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(toplab1);
        make.left.equalTo(toplab2.mas_right);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#D8D8D8");
    [backview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(48));
        make.left.offset(kwt(14));
        make.right.offset(kwt(-14));
        make.height.offset(0.5);
    }];
    
    UITableView * tableview = [UITableView new];
    tableview.delegate = self;
    tableview.dataSource = self;
    [backview addSubview:tableview];
    self.tableview = tableview;
    [tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.top.equalTo(line.mas_bottom);
    }];
    
    [self ReloadUI];
    
    [self show];
    
}
- (void)ReloadUI{
    int i = 0;
    for (pondModelListModel * model in self.array) {
        if(model.isSeled){
            i++;
        }
    }
    self.seledCount.text = [NSString stringWithFormat:@"%d",i];
    [self.tableview reloadData];
}

- (void)leftBtnclick{
    for (pondModelListModel * model in self.array) {
        model.isSeled = NO;
    }
    [self ReloadUI];
    
}

- (void)rightbtnclick{
    NSMutableArray * array = [NSMutableArray array];
    for (pondModelListModel * model in self.array) {
        if(model.isSeled){
            [array addObject:model.ID];
        }
    }
    if(array.count < 1){
        [self showWarning:@"至少有一个池塘"];
        return;
    }
    if(self.block){
        self.block(array);
    }
    [self dismiss];
}


- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.array.count;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return kwt(53);
}

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    MJWeakSelf
    
    foundQuestSelectPondTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"foundQuestSelectPondTableViewCell"];
    if (cell == nil) {
        cell = [[foundQuestSelectPondTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"foundQuestSelectPondTableViewCell"];
    }
    cell.model = self.array[indexPath.row];
    cell.reLoadBlock = ^{
        [weakSelf ReloadUI];
    };
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell ;
    
}


- (void)show{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT - self.viewH , SCREEN_WIDTH, self.viewH);
    }];
}
- (void)noclick{}
- (void)dismiss{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT , SCREEN_WIDTH, self.viewH);
    } completion:^(BOOL finished) {
        [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [self removeFromSuperview];
    }];
}




@end
@interface foundQuestSelectPondTableViewCell()

@property (nonatomic ,strong) UILabel * namelab;
@property (nonatomic ,strong) UIButton * btn;

@end
@implementation foundQuestSelectPondTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
     if (self)
     {
          [self setupView];
     }
     return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.whiteColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UILabel * namelab = [DTKTool labelWithText:@"-" andFont:kFont(17) andTextColor:KcolorHex(@"#222222")];
    [self.contentView addSubview:namelab];
    self.namelab = namelab;
    [namelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(14));
        make.centerY.offset(0);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#E5E3E3");
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(14));
        make.right.offset(kwt(-14));
        make.bottom.offset(0);
        make.height.offset(0.5);
    }];
    
    UIView * btnview = [UIView new];
    MJWeakSelf
    btnview.addClickBlock(^{
        [weakSelf BtnClick];
    });
    [self.contentView addSubview:btnview];
    [btnview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.top.offset(0);
        make.width.offset(kwt(200));
    }];
    
    UIButton * btn = [UIButton buttonWithType:0];
    self.btn = btn;
    [btn setImage:[UIImage imageNamed:@"departmentNoSeled"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"departmentSeled"] forState:UIControlStateSelected];
    [btn addTarget:self action:@selector(BtnClick) forControlEvents:UIControlEventTouchUpInside];
    [btnview addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-14));
        make.width.height.offset(kwt(18));
        make.centerY.offset(0);
    }];
    
    
}
- (void)setModel:(pondModelListModel *)model{
    _model = model;
    self.namelab.text = model.name;
    self.btn.selected = model.isSeled;
}
- (void)BtnClick{
    self.model.isSeled = !self.model.isSeled;
    if(self.reLoadBlock){
        self.reLoadBlock();
    }
}
@end

@interface foundYZZLSelectPondShowView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong) UIView * makeView;
@property (nonatomic ,assign) CGFloat viewH;
@property (nonatomic ,strong) UITableView * tableview;
@property (nonatomic ,strong) UILabel * seledCount;
@property (nonatomic ,strong) NSArray <getPondTissueListModel *> * array;
@property (nonatomic ,strong) void(^block)(NSArray <NSString *>* array);
@end

@implementation foundYZZLSelectPondShowView

+ (instancetype)showviewWithArray:(NSArray <getPondTissueListModel *>*)array andBlock:(void(^)(NSArray <NSString *>* array))block{
    foundYZZLSelectPondShowView * view = [foundYZZLSelectPondShowView new];
    view.array = array;
    view.block = block;
    [view setupview];
    return view;
}
- (void)setupview{
    [[DTKTool getCurrentVC].view addSubview:self];
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    self.viewH = kwt(400) + KSafeAreaBottomHeight;
    UIView * makeView = [UIView new];
    self.makeView = makeView;
    makeView.backgroundColor = KcolorHex(@"#EDF2F8");
    makeView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, kwt(170) + KSafeAreaBottomHeight);
    [self addSubview:makeView];
    [DTKTool BFYJ:kwt(15) andView:makeView andCorner:UIRectCornerTopLeft|UIRectCornerTopRight andSize: CGRectMake(0, 0 ,SCREEN_WIDTH, self.viewH + KSafeAreaBottomHeight)];
    
//    view.userInteractionEnabled = YES;
//    [view addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:view action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
    self.userInteractionEnabled = YES;
    [self addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
    
    UILabel * titlab = [DTKTool labelWithText:@"养殖种类" andFont:kFont(18) andTextColor:KcolorHex(@"#222222")];
    [makeView addSubview:titlab];
    [titlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(15));
    }];
    
    UIButton * btn = [UIButton buttonWithType:0];
    [btn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    btn.addTarget(self,@selector(dismiss));
    [makeView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.width.height.offset(kwt(20));
        make.centerY.equalTo(titlab);
    }];
    
    
    
    UIView * buttonview = [UIView new];
    [makeView addSubview:buttonview];
    buttonview.backgroundColor = UIColor.whiteColor;
    [buttonview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(kwt(68) + KSafeAreaBottomHeight);
    }];
    UILabel * temp1 = [DTKTool labelWithText:@"已选" andFont:kFont(15) andTextColor:KcolorHex(@"#5A6066")];
    [buttonview addSubview:temp1];
    [temp1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(26));
    }];
    UILabel * seledCount = [DTKTool labelWithText:@"0" andFont:kFont(15) andTextColor:KcolorHex(@"#0967FF")];
    self.seledCount = seledCount;
    [buttonview addSubview:seledCount];
    [seledCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(temp1.mas_right).offset(kwt(2));
        make.centerY.equalTo(temp1);
    }];
    
    UILabel * temp3 = [DTKTool labelWithText:@"个" andFont:kFont(15) andTextColor:KcolorHex(@"#5A6066")];
    [buttonview addSubview:temp3];
    [temp3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(seledCount.mas_right).offset(kwt(2));
        make.centerY.equalTo(temp1);
    }];
    UIButton * qxbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    qxbtn.backgroundColor = KcolorHex(@"#F0F2F4");
    [qxbtn setTitle:@"清空" forState:UIControlStateNormal];
    [qxbtn setTitleColor:KcolorHex(@"#5A6066") forState:UIControlStateNormal];
    qxbtn.titleLabel.font = kFont(17);
    [DTKTool YJ:kwt(5) andView:qxbtn];
    [qxbtn addTarget:self action:@selector(leftBtnclick) forControlEvents:UIControlEventTouchUpInside];
    [buttonview addSubview:qxbtn];
    [qxbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(kwt(44));
        make.width.offset(kwt(116));
        make.left.offset(kwt(118));
        make.top.offset(kwt(12));
    }];
    
    UIButton * qrbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    qrbtn.backgroundColor = [UIColor gradientColorWithSize:CGSizeMake(kwt(160), 1) direction:GradientColorDirectionLevel startColor:KcolorHex(@"#2892FE") endColor:KcolorHex(@"#0366FE")];
    [qrbtn setTitle:@"确定" forState:UIControlStateNormal];
    [qrbtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    qrbtn.titleLabel.font = kCFont(17);
    [DTKTool YJ:kwt(5) andView:qrbtn];
    [qrbtn addTarget:self action:@selector(rightbtnclick) forControlEvents:UIControlEventTouchUpInside];
    [buttonview addSubview:qrbtn];
    [qrbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(kwt(44));
        make.width.offset(kwt(116));
        make.right.offset(kwt(-15));
        make.top.offset(kwt(12));
    }];
    
    UIView * backview = [UIView new];
    backview.backgroundColor = UIColor.whiteColor;
    [DTKTool YJ:kwt(5) andView:backview];
    [makeView addSubview:backview];
    [backview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
        make.top.offset(kwt(47));
        make.bottom.equalTo(buttonview.mas_top).offset(kwt(-7));

    }];
    
    UILabel * toplab1= [DTKTool labelWithText:@"*" andFont:kCFont(17) andTextColor:KcolorHex(@"#FA0F0F")];
    [backview addSubview:toplab1];
    [toplab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(18));
        make.left.offset(kwt(14));
    }];
    
    UILabel * toplab2= [DTKTool labelWithText:@"选择养殖种类" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
    [backview addSubview:toplab2];
    [toplab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(toplab1);
        make.left.equalTo(toplab1.mas_right);
    }];
    
    UILabel * toplab3= [DTKTool labelWithText:@"(可选3)" andFont:kCFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
    [backview addSubview:toplab3];
    [toplab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(toplab1);
        make.left.equalTo(toplab2.mas_right);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#D8D8D8");
    [backview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(48));
        make.left.offset(kwt(14));
        make.right.offset(kwt(-14));
        make.height.offset(0.5);
    }];
    
    UITableView * tableview = [UITableView new];
    tableview.delegate = self;
    tableview.dataSource = self;
    [backview addSubview:tableview];
    self.tableview = tableview;
    [tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.top.equalTo(line.mas_bottom);
    }];
    
    [self ReloadUI];
    
    [self show];
    
}
- (void)ReloadUI{
    int i = 0;
    for (getPondTissueListModel * model in self.array) {
        if(model.seled){
            i++;
        }
    }
    self.seledCount.text = [NSString stringWithFormat:@"%d",i];
    [self.tableview reloadData];
}

- (void)leftBtnclick{
    for (getPondTissueListModel * model in self.array) {
        model.seled = NO;
    }
    [self ReloadUI];
    
}

- (void)rightbtnclick{
    NSMutableArray * array = [NSMutableArray array];
    for (getPondTissueListModel * model in self.array) {
        if(model.seled){
            [array addObject:model.ID];
        }
    }
    if(array.count < 1){
        [self showWarning:@"至少选择一种"];
        return;
    }
    if(self.block){
        self.block(array);
    }
    [self dismiss];
}


- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.array.count;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return kwt(53);
}

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    MJWeakSelf
    
    foundYZZLSelectPondTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"foundQuestSelectPondTableViewCell"];
    if (cell == nil) {
        cell = [[foundYZZLSelectPondTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"foundQuestSelectPondTableViewCell"];
    }
    cell.model = self.array[indexPath.row];
    cell.reLoadBlock = ^(getPondTissueListModel * _Nonnull model) {
        if(model.seled == NO){
            int i = 0;
            for (getPondTissueListModel * model in self.array) {
                if(model.seled){
                    i++;
                }
            }
            if(i > 2){
                [weakSelf showWarning:@"最多选择3个"];
                return;
            }
        }
        model.seled = !model.seled;
        [weakSelf ReloadUI];
    };
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell ;
    
}


- (void)show{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT - self.viewH , SCREEN_WIDTH, self.viewH);
    }];
}
- (void)noclick{}
- (void)dismiss{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT , SCREEN_WIDTH, self.viewH);
    } completion:^(BOOL finished) {
        [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [self removeFromSuperview];
    }];
}




@end
@interface foundYZZLSelectPondTableViewCell()

@property (nonatomic ,strong) UILabel * namelab;
@property (nonatomic ,strong) UIButton * btn;

@end
@implementation foundYZZLSelectPondTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
     if (self)
     {
          [self setupView];
     }
     return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.whiteColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UILabel * namelab = [DTKTool labelWithText:@"-" andFont:kFont(17) andTextColor:KcolorHex(@"#222222")];
    [self.contentView addSubview:namelab];
    self.namelab = namelab;
    [namelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(14));
        make.centerY.offset(0);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#E5E3E3");
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(14));
        make.right.offset(kwt(-14));
        make.bottom.offset(0);
        make.height.offset(0.5);
    }];
    
    UIView * btnview = [UIView new];
    MJWeakSelf
    btnview.addClickBlock(^{
        [weakSelf BtnClick];
    });
    [self.contentView addSubview:btnview];
    [btnview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.top.offset(0);
        make.width.offset(kwt(200));
    }];
    
    UIButton * btn = [UIButton buttonWithType:0];
    self.btn = btn;
    [btn setImage:[UIImage imageNamed:@"departmentNoSeled"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"departmentSeled"] forState:UIControlStateSelected];
    [btn addTarget:self action:@selector(BtnClick) forControlEvents:UIControlEventTouchUpInside];
    [btnview addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-14));
        make.width.height.offset(kwt(18));
        make.centerY.offset(0);
    }];
    
    
}
- (void)setModel:(getPondTissueListModel *)model{
    _model = model;
    self.namelab.text = model.name;
    self.btn.selected = model.seled;
}
- (void)BtnClick{
//    self.model.seled = !self.model.seled;
    if(self.reLoadBlock){
        self.reLoadBlock(self.model);
    }
}
@end
